#!/bin/python
from flask import *
import os
app = Flask(__name__)

Port=25569
CAFile = os.path.join(app.root_path, 'server.crt')
KeyFile = os.path.join(app.root_path, 'server.key')


@app.route('/')
def hello_world():
    return redirect('download')


# 下载
@app.route("/download", methods=['GET'])
def download():
    data = ""
    for i in range(1000):
        data = data+"\111"
    resp = make_response(data)
    return resp


# 上传
@app.route("/upload", methods=['POST'])
def upload():
    return "ok"+str(len(request.get_data()))


if __name__ == '__main__':
    print("Using CA:"+CAFile)
    print("Using Key:"+KeyFile)
    app.run(host="0.0.0.0", port=Port, debug=False,
            ssl_context=(CAFile, KeyFile))  # 在服务器上用
    # app.run()  # local debug
